<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>

<html>
	<head>
		<title>工单统计</title>
		<style>
			td{
				padding: 5px 20px;
			}
		</style>
		<script>
		$(function(){
			$('#end_date').datebox('setValue',getToday());
			$("#dept_id").combotree({
				url:'<%=contextPath %>/springMVC/group/listDepartment',
				method:'POST',
				animate:true,
				lines:true
			});
		});
		
		function doSearch(obj){
			var start_date = $('#start_date').datebox('getValue');
			if(start_date == null || start_date == ''){
				$.messager.alert("提示",'请选择期初时间');
				return;
			}
			var dept_id = $("#dept_id").combotree('getValue');
			var end_date = $('#end_date').datebox('getValue');
			if(end_date == null || end_date == ''){
				$.messager.alert("提示",'请选择期末时间');
				return;
			}
			$(obj).hide();
			$.ajax({
				type:'POST',
				url:'<%=contextPath %>/springMVC/statistic/gdStatistic',
				data:'start_date='+start_date+'&end_date='+end_date+'&dept_id='+dept_id,
				success:function(rtData){
					$('#num1').html(rtData.num1);
					$('#num2').html(rtData.num2);
					$('#num3').html(rtData.num3);
					$('#num4').html(rtData.num4);
					//$('#total1').html(rtData.num4);
					//$('#total2').html(rtData.num4);
					$('#num5').html(rtData.num5);
					$('#num6').html(rtData.num6);
					$('#num7').html(rtData.num7);
					if(rtData.num1 > 0){
						$('#detail1').show();
					}else{
						$('#detail1').hide();
					}
					if(rtData.num2 > 0){
						$('#detail2').show();
					}else{
						$('#detail2').hide();
					}
					if(rtData.num3 > 0){
						$('#detail3').show();
					}else{
						$('#detail3').hide();
					}
					if(rtData.num4 > 0){
						$('#detail4').show();
						//$('#detailT1').show();
						//$('#detailT2').show();
					}else{
						$('#detail4').hide();
						//$('#detailT1').hide();
						//$('#detailT2').hide();
					}
					if(rtData.num5 > 0){
						$('#detail5').show();
					}else{
						$('#detail5').hide();
					}
					if(rtData.num6 > 0){
						$('#detail6').show();
					}else{
						$('#detail6').hide();
					}
					if(rtData.num7 > 0){
						$('#detail7').show();
					}else{
						$('#detail7').hide();
					}
					$('#num8').html(rtData.num8);
					if(rtData.num8 > 0){
						$('#detail8').show();
					}
					else{
						$('#detail8').hide();
					}
					$('#num9').html(rtData.num9);
					if(rtData.num9 > 0){
						$('#detail9').show();
					}
					else{
						$('#detail9').hide();
					}
					$('#num10').html(rtData.num10);
					if(rtData.num10 > 0){
						$('#detail10').show();
					}
					else{
						$('#detail10').hide();
					}
					$('#num11').html(rtData.num11);
					if(rtData.num11 > 0){
						$('#detail11').show();
					}else{
						$('#detail11').hide();
					}
					$('#num12').html(rtData.num12);
					$('#num13').html(rtData.num13);
					$('#num14').html(rtData.num14);
					if(rtData.num12 > 0){
						$('#detail12').show();
					}else{
						$('#detail12').hide();
					}
					if(rtData.num13 > 0){
						$('#detail13').show();
					}else{
						$('#detail13').hide();
					}
					if(rtData.num14 > 0){
						$('#detail14').show();
					}else{
						$('#detail14').hide();
					}
					$('#date1').html(rtData.date1);
					$('#date2').html(rtData.date2);
					$('#date3').html(rtData.date3);
					$('#date4').html(rtData.date4);
					$('#date5').html(rtData.date5);
					$('#date6').html(rtData.date6);
					$('#date7').html(rtData.date7);
					$('#date8').html(rtData.date8);
					$('#date9').html(rtData.date9);
					$('#date10').html(rtData.date10);
					$(obj).show();
				}
			});
		}
		
		function show(type){
			var dept_id = $("#dept_id").combotree('getValue');
			var start_date = $('#start_date').datebox('getValue');
			var end_date = $('#end_date').datebox('getValue');
			if(end_date == null || end_date == ''){
				$.messager.alert("提示",'请选择期末时间');
				return;
			}
			var param = 'end_date='+end_date+'&dept_id='+dept_id+'&type='+type+'&start_date='+start_date;
			openDialogResize("<%=contextPath %>/springViews/statistic/gdStatisticDetail.jsp?"+param,1000, 800);
		}
		function gdPrint(){
			var start_date = $('#start_date').datebox('getValue');
			if(start_date == null || start_date == ''){
				$.messager.alert("提示",'请选择期初时间');
				return;
			}
			var dept_id = $("#dept_id").combotree('getValue');
			var end_date = $('#end_date').datebox('getValue');
			if(end_date == null || end_date == ''){
				$.messager.alert("提示",'请选择期末时间');
				return;
			}
			openDialogResize("<%=contextPath%>/springViews/print/startStatisticPrint.jsp?start_date="+start_date+"&end_date="+end_date+"&dept_id="+dept_id,2000, 800);
		}
		</script>
	</head>
<body>
	<div style="text-align: center;">
					<p style="font-weight: bolder;font-size: 20px">工单统计</p>
	</div>
	<div class="easyui-panel" title="查询条件">
			<table>
				<tr>
					<td align="right" nowrap>期初时间</td>
					<td align="left"><input id="start_date" name="start_date" class="easyui-datebox"></td>
					<td align="right" nowrap>期末时间</td>
					<td align="left"><input id="end_date" name="end_date" class="easyui-datebox"></td>
					<td align="right" nowrap>统计部门</td>
					<td align="left"><input  id="dept_id" name="dept_id" class="easyui-combotree"></td>
					<td align="left">
					<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="doSearch(this);">查询</a>
					<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-print',plain:false" onclick="gdPrint();">打印预览</a>
					</td>
				</tr>
			</table>
		</div>
	<table style="width:100%;border-collapse: collapse;" border="1px" bordercolor="#0eb83a" >
		<tr>
			<td align="center"><span style="font-weight: bolder;">统计类别</span></td>
			<td align="center"><span style="font-weight: bolder;">计数</span></td>
			<td align="center"><span style="font-weight: bolder;">详情 </span></td>
			<td align="center"><span style="font-weight: bolder;">未关闭工单分析</span></td>
			<td align="center"><span style="font-weight: bolder;">计数</span></td>
			<td align="center"><span style="font-weight: bolder;">详情 </span></td>
		</tr>
		<tr>
			<td align="center"><span style="font-weight: bolder;">期初统计数</span></td>
			<td align="center"><span style="font-weight: bolder;" id="num1"></span></td>
			<td align="center"><input id="detail1" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(7)'/></td>
			<td align="center"><span style="font-weight: bolder;">开工三个月内工单数<br><span id="date1"></span>-<span id="date2"></span></span></td>
			<td align="center"><span style="font-weight: bolder;" id="num7"></span></td>
			<td align="center"><input id="detail7" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(1)'/></td>
		</tr>
		<tr>
			<td align="center"><span style="font-weight: bolder;">本期新增数</span></td>
			<td align="center"><span style="font-weight: bolder;" id="num2"></span></td>
			<td align="center"><input id="detail2" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(8)'/></td>
			<td align="center"><span style="font-weight: bolder;">开工三至六个月工单数<br><span id="date3"></span>-<span id="date4"></span></span></td>
			<td align="center"><span style="font-weight: bolder;" id="num8"></span></td>
			<td align="center"><input id="detail8" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(2)'/></td>
		</tr>
		<tr>
			<td align="center"><span style="font-weight: bolder;">本期关闭数</span></td>
			<td align="center"><span style="font-weight: bolder;" id="num3"></span></td>
			<td align="center"><input id="detail3" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(9)'/></td>
			<td align="center"><span style="font-weight: bolder;">开工六至十二个月工单数<br><span id="date5"></span>-<span id="date6"></span></span></td>
			<td align="center"><span style="font-weight: bolder;" id="num9"></span></td>
			<td align="center"><input id="detail9" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(3)'/></td>
		</tr>
		<tr>
			<td align="center"><span style="font-weight: bolder;">未关闭数量合计</span></td>
			<td align="center"><span style="font-weight: bolder;" id="num4"></span></td>
		    <td align="center"><input id="detail4" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(10)'/></td>
			<td align="center"><span style="font-weight: bolder;">开工一至两年工单数<br><span id="date7"></span>-<span id="date8"></span></span></td>
			<td align="center"><span style="font-weight: bolder;" id="num10"></span></td>
			<td align="center"><input id="detail10" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(4)'/></td>
		</tr>
		<tr>
			<td align="center"><span style="font-weight: bolder;">已关闭数量</span></td>
			<td align="center"><span style="font-weight: bolder;" id="num5"></span></td>
			<td align="center"><input id="detail5" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(11)'/></td>
			<td align="center"><span style="font-weight: bolder;">开工二年以上工单数<br><span id="date9"></span>-<span id="date10"></span></span></td>
			<td align="center"><span style="font-weight: bolder;" id="num11"></span></td>
			<td align="center"><input id="detail11" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(5)'/></td>
		</tr>
		<tr>
			<td align="center"><span style="font-weight: bolder;">工单总计</span></td>
			<td align="center"><span style="font-weight: bolder;" id="num6"></span></td>
			<td align="center"><input id="detail6" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(12)'/></td>
			<td align="center"><span style="font-weight: bolder;">已立项工单数</span></td>
			<td align="center"><span style="font-weight: bolder;" id="num12"></span></td>
			<td align="center"><input id="detail12" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(14)'/></td>
		</tr>
		<tr>
			<td align="center"></td>
			<td align="center"></td>
			<td align="center"></td>
		<td align="center"><span style="font-weight: bolder;">未立项工单数</span></td>
			<td align="center"><span style="font-weight: bolder;" id="num13"></span></td>
			<td align="center"><input id="detail13" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(15)'/></td>
		</tr>
		<tr>
			<td align="center"></td>
			<td align="center"></td>
			<td align="center"></td>
			<td align="center"><span style="font-weight: bolder;">超期未立项工单数</span><br>(开工一年以上未归属项目的工单为超期)</td>
			<td align="center"><span style="font-weight: bolder;" id="num14"></span></td>
			<td align="center"><input id="detail14" type='button' style='border:0px #ff0000 solid;width:16px;height:16px;cursor:pointer;display:none;' class='icon-details' title='查看详情' onclick='show(17)'/></td>
		</tr>
	</table>
	<br>
	<br>
</body>
</html>
